package com.itstherules.jmsunit.loaders;

import org.junit.Assert;
import org.junit.Test;


public class SchemaLoadingTest {

	static final String SEPARATOR = System.getProperty("line.separator");

	@Test
	public void canLoadSchemaAsStringFromRootFolder() throws Exception {
		FileLoader unit = new SchemaLoader();
		String reply = unit.load("test_schema");
		Assert.assertEquals(
				"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>" + SEPARATOR +
				"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + SEPARATOR +
				"	<xs:element name=\"shiporder\">" + SEPARATOR +
				"		<xs:complexType>" + SEPARATOR +
				"			<xs:sequence>" + SEPARATOR +
				"				<xs:element name=\"orderperson\" type=\"xs:string\" />" + SEPARATOR +
				"			</xs:sequence>" + SEPARATOR +
				"			<xs:attribute name=\"orderid\" type=\"xs:string\"" + SEPARATOR +
				"				use=\"required\" />" + SEPARATOR +
				"		</xs:complexType>" + SEPARATOR +
				"	</xs:element>" + SEPARATOR +
				"</xs:schema>", reply);
	}

	@Test(expected=IllegalArgumentException.class)
	public void cannotLoadSchemaAsStringFromRootFolder() throws Exception {
		FileLoader unit = new SchemaLoader();
		unit.load("invalid_test_schema");
	}
	
}
